<template>
	<div>
		<el-breadcrumb separator-class="el-icon-arrow-right">
		  	<el-breadcrumb-item :to="{ path: '/admin' }">homepage</el-breadcrumb-item>
		  	<el-breadcrumb-item>EditAccount</el-breadcrumb-item>
		</el-breadcrumb>
		<el-form ref="form" :model="formData" label-width="160px">
		  	<el-form-item label="Account">
		    	<el-input v-model="formData.LoginEmail" :disabled="formData.level==1" ></el-input>
		  	</el-form-item> 

		  <!--	<el-form-item label="密码">
		    	<el-input v-model="formData.password" :disabled="formData.level==1"></el-input>
		  	</el-form-item> -->
		  	
		  	<el-form-item label="EmployeeName">
		    	<el-input v-model="formData.employeeName" :disabled="formData.level==1" ></el-input>
		  	</el-form-item> 
		  	
		  	<el-form-item>
		    	<el-button type="primary" @click="addUser">Edit Account</el-button>
		    	<el-button>Cancel</el-button>
		  	</el-form-item>
		</el-form>
	</div>
</template>

<script type="text/javascript">
	export default{
		data(){
			return{
				formData:{
					employeeName:"",
					LoginEmail:"",
				},
				username:'',
				disabled:'',
			}
		},
		created(){
			//this.formData._token = window.axios.defaults.headers.common['X-CSRF-TOKEN'];
			this.getUserInfo();
			//this.formData.id = this.$route.params.id;
		},
		methods:{
			handleRemove(file, fileList) {
		        console.log(file, fileList);
		    },
		    handlePreview(file) {
		        console.log(file);
		   	},
		    handlePictureCardPreview(file) {
		        this.dialogImageUrl = file.url;
		        this.dialogVisible = true;
		    },
		    handleExceed(files, fileList) {
	        	this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
	      	},
		    beforeRemove(file, fileList) {
		        return this.$confirm(`确定移除 ${ file.name }？`);
		    },
		    addUser(){
		    	axios.post('/api/admin/edit',this.formData)
		    		.then(result => {
		    			if(result.data.code == 200){
		    				this.$notify({
		    					type:"success",
		    					message:result.data.message
		    				})
		    			}else{
		    				this.$notify.error(result.data.message);
		    			}
		    		})
		    		.catch(error => {

		    		})
		    },
		    getUserInfo(){
		    	axios.get("/api/admin/admindetail?id="+this.$route.query.id )
		    		.then(res => {
		    			var data = res.data.result[0];
		    			if(res.data.code == 200){
		    				this.formData.LoginEmail = data.LoginEmail;
		    				this.formData.employeeName = data.employeeName;
		    				this.formData.employeeid = data.employeeid;
		    			}
		    		})
		    },
	        addTime(m){
	    	return m<10?'0'+m:m 
		    },
			timeFormat(shijianchuo)
			{
				//shijianchuo是整数，否则要parseInt转换
				var sjc =shijianchuo *1000;
				var time = new Date(sjc);
				var y = time.getFullYear();
				var m = time.getMonth()+1;
				var d = time.getDate();
				var h = time.getHours();
				var mm = time.getMinutes();
				var s = time.getSeconds();
				return y+'-'+this.addTime(m)+'-'+this.addTime(d)+' '+this.addTime(h)+':'+this.addTime(mm)+':'+this.addTime(s);
			},
		}
	}
</script>

<style type="text/css">
	input[type=file] {
	    display: none;
	}
</style>